package com.ruoyi.car.controller.carmanage;

import java.util.List;

import com.car.pojo.TbCarUpdateRecord;
import com.car.vo.VoCarUpdateRecord;
import com.ruoyi.car.service.carmanage.TbCarUpdateRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.car.pojo.TbCarUpdateRecord;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆修改记录Controller
 *
 * @author 敬乾超
 * @date 2020-06-24
 */
@Controller
@RequestMapping("/car/carUpdateRecord")
public class TbCarUpdateRecordController extends BaseController
{
    private String prefix = "carmanage/carUpdateRecord";

    @Autowired
    private TbCarUpdateRecordService tbCarUpdateRecordService;

    @RequiresPermissions("car:carUpdateRecord:view")
    @GetMapping()
    public String carUpdateRecord()
    {
        return prefix + "/carUpdateRecord";
    }

//    /**
//     * 查询车辆修改记录列表
//     */
//    @RequiresPermissions("car:carUpdateRecord:list")
//    @PostMapping("/list")
//    @ResponseBody
//    public TableDataInfo list(TbCarUpdateRecord tbCarUpdateRecord)
//    {
//        startPage();
//        List<TbCarUpdateRecord> list = tbCarUpdateRecordService.selectTbCarUpdateRecordList(tbCarUpdateRecord);
//        return getDataTable(list);
//    }

    /**
     * 导出车辆修改记录列表
     */
    @RequiresPermissions("car:carUpdateRecord:export")
    @Log(title = "车辆修改记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbCarUpdateRecord tbCarUpdateRecord)
    {
        List<TbCarUpdateRecord> list = tbCarUpdateRecordService.selectTbCarUpdateRecordList(tbCarUpdateRecord);
        ExcelUtil<TbCarUpdateRecord> util = new ExcelUtil<TbCarUpdateRecord>(TbCarUpdateRecord.class);
        return util.exportExcel(list, "carUpdateRecord");
    }

    /**
     * 新增车辆修改记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存车辆修改记录
     */
    @RequiresPermissions("car:carUpdateRecord:add")
    @Log(title = "车辆修改记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbCarUpdateRecord tbCarUpdateRecord)
    {
        return toAjax(tbCarUpdateRecordService.insertTbCarUpdateRecord(tbCarUpdateRecord));
    }

    /**
     * 修改车辆修改记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TbCarUpdateRecord tbCarUpdateRecord = tbCarUpdateRecordService.selectTbCarUpdateRecordById(id);
        mmap.put("tbCarUpdateRecord", tbCarUpdateRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存车辆修改记录
     */
    @RequiresPermissions("car:carUpdateRecord:edit")
    @Log(title = "车辆修改记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbCarUpdateRecord tbCarUpdateRecord)
    {
        return toAjax(tbCarUpdateRecordService.updateTbCarUpdateRecord(tbCarUpdateRecord));
    }

    /**
     * 删除车辆修改记录
     */
    @RequiresPermissions("car:carUpdateRecord:remove")
    @Log(title = "车辆修改记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbCarUpdateRecordService.deleteTbCarUpdateRecordByIds(ids));
    }







    @PostMapping("getData")
    @ResponseBody
    public TableDataInfo getTestData(TbCarUpdateRecord record){
        startPage();
        List<VoCarUpdateRecord> list = tbCarUpdateRecordService.getTestData(record);
        return getDataTable(list);
    }


}
